package com.bob.clan.wxconnector.exception;

/**
 * Created by fs.ge on 2016/12/8.
 */
public class MpException extends Exception {
    public final static int MpNotExist = -10001;
    public final static int MpNotOpenVoice = -10101;
    public final static int ConfigKeyNotExist = -20001;
    public final static int ConfigDataTypeError = -20002;
    public final static int QRSceneIdNotExist = -30001;
    public final static int MpNoTempId = -40001;
    public final static int FansNotExist = -50001;
    public final static int FansSaveFail = -50002;
    public final static int EventSceneIllegal = -60001;
    public final static int TokenInvalidHit = 40001;

    private int code;



    private static String getMessage(int code,String errMsg) {
        String errDesc = "";
        switch (code) {
            case MpNotExist:
                errDesc = "公众号的唯一号未报备,MP表无该mpid。";
                break;
            case MpNotOpenVoice:
                errDesc = "公众号未开通语音识别功能。";
                break;
            case ConfigKeyNotExist:
                errDesc = "公众号个性化属性无该配置，MpConfig表里无configKey属性。";
                break;
            case ConfigDataTypeError:
                errDesc = "公众号个性化属性配置的数据类型出错，MpConfig表里configValue数据类型不对。";
                break;
            case QRSceneIdNotExist:
                errDesc = "公众号参数二维码场景ID未定义，MPQR表的sceneId不存在。";
                break;
            case MpNoTempId:
                errDesc = "公众号未配置该模板消息，请完善数据库Mp_temp_msg表的配置信息。";
                break;
            case FansNotExist:
                errDesc = "该用户还未关注服务号，请他先成为粉丝。";
                break;
            case FansSaveFail:
                errDesc = "粉丝信息入库失败，未生效本地库的fansID。";
                break;
            case EventSceneIllegal:
                errDesc = "事件场景ID不合法。";
                break;
            case TokenInvalidHit:
                errDesc = "accecss token 不是最后更新的";
                break;
        }
        errDesc = errDesc + errMsg;
        return errDesc;
    }

    public MpException(int errCode, String errMsg) {
        super(getMessage(errCode,errMsg));
        this.code = errCode;
    }

    public int getCode() {
        return code;
    }

}
